Skip to content

Check malloc return value in utmp_db_add#125

Open
karinakbataeva wants to merge 1 commit into
hackerschoice:masterfrom
karinakbataeva:fix-malloc-null-check
Open

Check malloc return value in utmp_db_add#125
karinakbataeva wants to merge 1 commit into
hackerschoice:masterfrom
karinakbataeva:fix-malloc-null-check

Conversation

@karinakbataeva

Copy link
Copy Markdown

Summary

This PR adds a NULL check after malloc() in utmp_db_add().

Previously, if malloc() failed, the code would immediately dereference new, potentially causing a segmentation fault.

new = malloc(sizeof new);
new->idle = idle; /
possible NULL dereference */

The function now returns NULL when memory allocation fails, preventing a potential crash.

Fixes #124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

malloc return value unchecked in utmp_db_add

1 participant